package com.baiqian.doupo.event;

import com.baiqian.doupo.block.BlockRegistry;
import com.baiqian.doupo.entity.EntityTypeRegistry;
import com.baiqian.doupo.fluids.FluidsRegistry;
import com.baiqian.doupo.renderer.DouJiShiShanLieRender;
import com.baiqian.doupo.tileentity.TileEntityTypeRegistry;
import com.baiqian.doupo.tileentityrenderer.HuoDingTER;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;

@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
public class ClientEventHandler {
    @SubscribeEvent
    public static void onClientSetUpEvent(FMLClientSetupEvent event) {
        RenderingRegistry.registerEntityRenderingHandler(EntityTypeRegistry.doujiShiShanLieEntity.get(), (EntityRendererManager manager) -> {
            return new DouJiShiShanLieRender(manager);
        });
        event.enqueueWork(() -> {
            ClientRegistry.bindTileEntityRenderer(TileEntityTypeRegistry.huo_ding_tileentity.get(), HuoDingTER::new);
        });
    }

    /**流体注册*/
    @SubscribeEvent
    public static void onRenderTypeSetup(FMLClientSetupEvent event) {
        event.enqueueWork(() -> {
            RenderTypeLookup.setRenderLayer(FluidsRegistry.zhu_ji_ling_ye_fluid.get(), RenderType.getTranslucent());
            RenderTypeLookup.setRenderLayer(FluidsRegistry.zhu_ji_ling_ye_fluid_flowing.get(), RenderType.getTranslucent());
        });
        RenderTypeLookup.setRenderLayer(BlockRegistry.zi_ye_lan_cao.get(), RenderType.getCutout());
        RenderTypeLookup.setRenderLayer(BlockRegistry.xi_gu_hua.get(), RenderType.getCutout());
    }

    //指定物品变颜色
//    @SubscribeEvent
//    public static void registerItemColors(ColorHandlerEvent.Item event){
//        ItemColors colors = event.getItemColors();
//        colors.register((stack, i) ->  0xff0000, ItemRegistry.tun_mu_hu_de_mo_he.get());
//    }
}
